package initialize

import (
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
	"os"
)

func MustNewRedis(host string, password string, db int) *redis.Client {
	client := redis.NewClient(&redis.Options{
		Addr:     host,
		Password: password,
		DB:       db,
	})
	_, err := client.Ping(context.Background()).Result()
	if err != nil {
		fmt.Println("redis连接失败")
		os.Exit(-1)
	}
	return client
}
